import random
n = 1
p_count = 0
m_count = 0
while n <= 3:
    # 机器猜拳,产生数字0、1、2
    Answer = random.randint(0,2)
    # 个人猜拳
    Guess = int(input("请输入剪刀（0）、石头（1）、布（2）：\n"))
    # 比较判断
    if (Guess == 0 and Answer == 2) or (Guess == 1 and Answer == 0) or (Guess == 2 and Answer == 1):
        print("---这局你赢了！---")
        p_count += 1
    elif (Guess == 0 and Answer == 1) or (Guess == 1 and Answer == 2) or (Guess == 2 and Answer == 0):
        print("---这局机器赢了！---")
        m_count += 1
    else:
        print("---这局平局---")
    # n的变化
    n += 1
# 比较胜负
if p_count > m_count:
    print("~~~恭喜！最后你赢了！~~~")
elif p_count < m_count:
    print("~~~三局两胜，机器赢了！~~~")
else:
    print("\n~~~最终是平局！~~~")